﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using Box.Entities;
using Box.Repository.Mapping;

namespace Box.Repository
{
    public class BoxSportSystemContext:DbContext
    {
        static BoxSportSystemContext()
        {
            Database.SetInitializer<BoxSportSystemContext>
            (
               null
               //new DropCreateDatabaseIfModelChanges<BoxSportSystemContext>()
               //new DropCreateDatabaseAlways<BoxSportSystemContext>()
                //new CreateDatabaseIfNotExists<BoxSportSystemContext>()

                );
        }
        public BoxSportSystemContext()
            : base("Name=BoxSportSystemContext")
        {
            this.Configuration.LazyLoadingEnabled = false;
            this.Configuration.ProxyCreationEnabled = false;
            this.Configuration.AutoDetectChangesEnabled = false;

        }

        public DbSet<Categoria> Categorias { get; set; }
        public DbSet<Cliente> Clientes { get; set; }
        public DbSet<Compra> Compras { get; set; }
        public DbSet<DetalleCompra> DetalleCompras { get; set; }
        public DbSet<DetalleVenta> DetalleVentas { get; set; }
        public DbSet<DetallKits> DetallKits { get; set; }
        public DbSet<Insumo> Insumos { get; set; }
        public DbSet<Kit> Kits { get; set; }
        public DbSet<Pagos> Pagos { get; set; }
        public DbSet<Producto> Productos { get; set; }
        public DbSet<Proveedor> Proveedores { get; set; }
        public DbSet<TipoProducto> TipoProductos { get; set; }
        public DbSet<Venta> Ventas { get; set; }
        public DbSet<DetalleCatalogoProductos> DetalleCatalogoProductos { get; set; }
        
        

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new CategoriaMap());
            modelBuilder.Configurations.Add(new ClienteMap());
            modelBuilder.Configurations.Add(new ComprasMap());
            modelBuilder.Configurations.Add(new DetalleCompraMap());
            
            modelBuilder.Configurations.Add(new DetalleVentaMap());
            modelBuilder.Configurations.Add(new DetalleKitMap());
            modelBuilder.Configurations.Add(new InsumosMap());
            modelBuilder.Configurations.Add(new KitMap());
            modelBuilder.Configurations.Add(new PagosMap());
            modelBuilder.Configurations.Add(new ProductoMap());
            modelBuilder.Configurations.Add(new ProveedorMap());
            modelBuilder.Configurations.Add(new TipoProductoMap());
            modelBuilder.Configurations.Add(new VentasMap());
            modelBuilder.Configurations.Add(new DetalleCatalogoProductoMap());
            
        }
    }
}
